package com.ruoyi.yipaiju.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yipaiju.domain.Qa;
import com.ruoyi.yipaiju.service.IQaService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * fo_qaController
 * 
 * @author liuwp
 * @date 2023-03-01
 */
@RestController
@RequestMapping("/yipaiju/qa")
public class QaController extends BaseController
{
    @Autowired
    private IQaService qaService;

    /**
     * 查询fo_qa列表
     */
    @PreAuthorize("@ss.hasPermi('yipaiju:qa:list')")
    @GetMapping("/list")
    public TableDataInfo list(Qa qa)
    {
        startPage();
        List<Qa> list = qaService.selectQaList(qa);
        return getDataTable(list);
    }

    /**
     * 导出fo_qa列表
     */
    @PreAuthorize("@ss.hasPermi('yipaiju:qa:export')")
    @Log(title = "fo_qa", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Qa qa)
    {
        List<Qa> list = qaService.selectQaList(qa);
        ExcelUtil<Qa> util = new ExcelUtil<Qa>(Qa.class);
        util.exportExcel(response, list, "fo_qa数据");
    }

    /**
     * 获取fo_qa详细信息
     */
    @PreAuthorize("@ss.hasPermi('yipaiju:qa:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(qaService.selectQaById(id));
    }

    /**
     * 新增fo_qa
     */
    @PreAuthorize("@ss.hasPermi('yipaiju:qa:add')")
    @Log(title = "fo_qa", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Qa qa)
    {
        return toAjax(qaService.insertQa(qa));
    }

    /**
     * 修改fo_qa
     */
    @PreAuthorize("@ss.hasPermi('yipaiju:qa:edit')")
    @Log(title = "fo_qa", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Qa qa)
    {
        return toAjax(qaService.updateQa(qa));
    }

    /**
     * 删除fo_qa
     */
    @PreAuthorize("@ss.hasPermi('yipaiju:qa:remove')")
    @Log(title = "fo_qa", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(qaService.deleteQaByIds(ids));
    }
}
